package com.ysj.demo.accompanynetwork.fragment;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.ysj.demo.accompanynetwork.R;
import com.ysj.demo.accompanynetwork.activity.IFollowActivity;
import com.ysj.demo.accompanynetwork.activity.IIssuedInformationActivity;
import com.ysj.demo.accompanynetwork.activity.PersonalCenterActivity;
import com.ysj.demo.accompanynetwork.activity.PlaymateCoinActivity;

public class UserFragment extends Fragment implements View.OnClickListener {
    private View view;
    private TextView titleTv, centerTv, playmateTv, issuedTv, followTv;
    private Button loginOutBtn;

    public UserFragment() {
        // Required empty public constructor
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        view = inflater.inflate(R.layout.fragment_user, container, false);
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        titleTv = view.findViewById(R.id.top_tv);
        titleTv.setText("我");
        centerTv = view.findViewById(R.id.personal_center_tv);
        centerTv.setOnClickListener(this);
        playmateTv = view.findViewById(R.id.playmate_coin_tv);
        playmateTv.setOnClickListener(this);
        issuedTv = view.findViewById(R.id.i_issued_information_tv);
        issuedTv.setOnClickListener(this);
        followTv = view.findViewById(R.id.i_follow_tv);
        followTv.setOnClickListener(this);
        loginOutBtn = view.findViewById(R.id.safe_login_out_btn);
        loginOutBtn.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            //个人中心
            case R.id.personal_center_tv:
                Intent intent = new Intent(getActivity(), PersonalCenterActivity.class);
                startActivity(intent);
                break;
            //我的玩伴币
            case R.id.playmate_coin_tv:
                Intent twoIntent = new Intent(getActivity(), PlaymateCoinActivity.class);
                startActivity(twoIntent);
                break;
            //我发布的信息
            case R.id.i_issued_information_tv:
                Intent threeIntent = new Intent(getActivity(), IIssuedInformationActivity.class);
                startActivity(threeIntent);
                break;
            //我关注的
            case R.id.i_follow_tv:
                Intent fourIntent = new Intent(getActivity(), IFollowActivity.class);
                startActivity(fourIntent);
                break;
            //安全退出
            case R.id.safe_login_out_btn:

                break;
        }
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);

    }

    @Override
    public void onDetach() {
        super.onDetach();

    }

}
